/**
 * This is also the interface to the call button
 */
package bedside;

import java.io.Serializable;
import java.rmi.RemoteException;

import common.CallRequestReceiver;

public class CallButton implements Serializable {
	//Class Constants
	final static int OFF = 0;
	final static int ON = 1;

	
	//Class Variables
	private int myMode;
	private CallRequestReceiver myCrr = null;
	
	/**
	 * Basic Instantiation
	 */
	public CallButton(CallRequestReceiver newCrr){
		myMode = OFF;
		myCrr = newCrr;
	}
	
	/**
	 * Turns the Call Button off, this can be done by the presiding nurse
	 */
	public void acknowledge(){
		myMode = CallButton.OFF;
		notifyNursesStation();
	}
	
	/**
	 * In the process of activation this call button will 
	 * notify the nurses station of its status
	 */
	public void activate(){
		myMode = CallButton.ON;
		notifyNursesStation();
	}
	
	/**
	 * This Method will call out to the Nurses Station to 
	 * inform the station of its state
	 */
	private void notifyNursesStation(){
		//Local Variables
		
		/**************main body*************/
		try {
			//Call My Call Request Receiver with my current state
			if( myMode == CallButton.OFF ){
				myCrr.callButtonReset();
			}else if( myMode == CallButton.ON ){
				myCrr.callRequest();
			}
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		//TODO Figure this out
		//Send to the Nurses Station my State
		
		
	}
	
	
	
}
